package com.hlhj.carview.aty

import android.support.v7.widget.LinearLayoutManager
import com.bumptech.glide.Glide
import com.hlhj.carview.BaseAty
import com.hlhj.carview.Iview.AdvDetailView
import com.hlhj.carview.R
import com.hlhj.carview.adapter.AdvAdp
import com.hlhj.carview.bean.AdvDetailBean
import com.hlhj.carview.http.Urls
import com.hlhj.carview.presenter.AdvDetailPresenter
import kotlinx.android.synthetic.main.aty_adv_detail.*
import kotlinx.android.synthetic.main.lo_pubhead.*

/**
 * Created by Never Fear   on 2018\12\24 0024.
Never More....
 */
class AdvDetailAty :BaseAty<AdvDetailView,AdvDetailPresenter>(), AdvDetailView {
    private var isMonth=false
    private var adp:AdvAdp?=null
    private val datas=ArrayList<AdvDetailBean.InfoBean.RoyaltyBean>()
    override fun setDetail(advDetailBean: AdvDetailBean) {
        Glide.with(this).load(Urls.Img+advDetailBean.info.cover).into(advIcon)
        name.text="${advDetailBean.info.advertising_name}"
        owner.text="${advDetailBean.info.advertiser}"

        datas.addAll(advDetailBean.info.royalty)
        adp?.notifyDataSetChanged()
    }

    override fun initView() {
        tvTittle.text="广告详情"


        adp=AdvAdp(datas)
        listView?.layoutManager=LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false)
        listView?.adapter=adp


    }

    override fun logicStart() {
        presenter?.getDetail(intent.getIntExtra("id",0),this)
        presenter?.choucheng(intent.getIntExtra("id",0),intent.getStringExtra("name"),this)
    }

    override fun setListener() {
        btTime.setOnClickListener {
            if (!isMonth){
                btTime.setImageResource(R.drawable.ic_choose_month)
            }else{
                btTime.setImageResource(R.drawable.ic_choose_day)
            }
            isMonth=!isMonth
        }
    }

    override fun bindView(): AdvDetailView {
        return this
    }

    override fun createPresenter(): AdvDetailPresenter {
        return AdvDetailPresenter()
    }

    override fun getContentID(): Int {
        return R.layout.aty_adv_detail
    }
}